<template>
  <div class="main-content">
    <div class="article">

      <ul class="article-list">
        <li v-for="(item, index) in ArticleList" :key="index">

          <div class="article-item-wrapper">
            <router-link :to="{ name: 'page', params: { id: item['articleId'] }}">
              <div class="article-item-left" >
                <div class="article-item-left-text">{{ item.title }}</div>
                <div>{{ item.username }}</div>
                <div>{{ item.createTime }}</div>
              </div>
            </router-link>
            <div class="article-item-right">
              <el-button v-if="uId === 1" @click="ChangeArticle(item.articleId)" type="primary">修改</el-button>
              <el-button v-if="uId === 1" @click="DeleteArticle" type="danger">删除</el-button>
            </div>
          </div>
        </li>
      </ul>

    </div>
  </div>
</template>

<script>
import {articleList} from "@/utils/api";
import {parseTime} from "../../public/FormatTime";

export default {
  name: 'ArticleList',
  data() {
    return {
      uid: 0
    }
  },
  props: {
    ArticleList: Array,
    uId: Number
  },
  methods: {

    ChangeArticle(articleId){
      this.$router.push({ name: 'changepage', params: { id: articleId } });
    },
    DeleteArticle() {
    }
  },
  mounted() {
    this.getArticle()
    console.log(this.ArticleList)

  }

}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.main-content {
  width: 1066px;
  height: 5533px;
  box-sizing: border-box;
  margin: 0 auto;
  padding: 16px 16px 0;

}

.article-item-wrapper {
  display: flex;
  justify-content: space-between; /* 这将左右对齐内容 */
  height: 120px;
}

.article-item-right {
  display: flex;
  align-items: center; /* 垂直居中按钮 */
}

.article-list {
  width: 80%;

  margin: 10px auto;
}

.article-list li {
  height: 120px;
}

.article-item-left {
  width: 600px;
  height: 100%;
  text-align: center;
  margin: 5px auto;
  border: 2px solid gray;
  border-radius: 4px;
}

.article-item-left-text {
  color: #222222;
  margin-top: 20px;
}
</style>
